package com.eidos.blogs.openapi.controller.seckill;

import com.eidos.blogs.openapi.controller.BaseController;
import com.eidos.blogs.openapi.entity.seckill.RedeInfo;
import com.eidos.blogs.openapi.service.seckill.IRedeInfoService;
import com.eidos.blogs.openapi.rest.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;


import javax.servlet.http.HttpServletRequest;


import java.util.List;


/**
* @author ： Eidos
* @date ：Created in 2021-01-12
* @description：红包信息表 Controller接口
* @modified By：
* @version: 1.0
*/
@Api(tags = "红包信息表")
@RestController
@RequestMapping("sec-kill/rede-info")
public class RedeInfoController extends BaseController {

    @Autowired
    private IRedeInfoService iRedeInfoService;

    @ApiOperation(value = "红包信息表分页列表")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "pageNo", value = "页面", dataType = "Long"),
    @ApiImplicitParam(name = "pageSize", value = "页面数据量", dataType = "Long"),
    @ApiImplicitParam(name = "sort", value = "排序方式排序[true:正序; false:倒序]", dataType = "Boolean"),
    @ApiImplicitParam(name = "sortName", value = "排序字段,参照返回字段", dataType = "String")})
    @PostMapping(value = "/page.do")
    public Resp<IPage<RedeInfo>> list(HttpServletRequest request , @RequestBody RedeInfo param) {
        return Resp.success(iRedeInfoService.page(param));
    }

    @ApiOperation(value = "红包信息表详情")
    @GetMapping(value = "/info/{id}")
    public  Resp<?> info(HttpServletRequest request , @RequestParam(required = false) Long id) {
        return Resp.success(iRedeInfoService.info(id));
    }

    @ApiOperation(value = "红包信息表新增")
    @PostMapping(value = "/add.do")
    public  Resp<?> add(HttpServletRequest request , @RequestBody RedeInfo param) {
        iRedeInfoService.add(param);
        return Resp.success();
    }

    @ApiOperation(value = "红包信息表修改")
    @PostMapping(value = "/modify.do")
    public  Resp<?> modify(HttpServletRequest request, @RequestBody RedeInfo param) {
        iRedeInfoService.modify(param);
        return Resp.success();
    }

    @ApiOperation(value = "红包信息表删除(单个条目)")
    @GetMapping(value = "/remove/{id}")
    public  Resp<?> remove(@PathVariable Long id) {
        iRedeInfoService.remove(id);
        return Resp.success();
    }

    @ApiOperation(value = "红包信息表删除(多个条目)")
    @PostMapping(value = "/removes.do")
    public  Resp<?> removes( @RequestBody List<Long> ids) {
        iRedeInfoService.removes(ids);
        return Resp.success();
    }

}
